package domain.entities.impl;

import java.util.Set;

import domain.entities.interfaces.IContactGroup;
import domain.entities.interfaces.IUser;

public class User implements IUser {

	private int id;
	private String login;
	private String password;
	private Set<IContactGroup> contactGroups;
	private int version;



	public int getVersion() {
		return version;
	}

	public void setVersion(int version) {
		this.version = version;
	}


	/* (non-Javadoc)
	 * @see domain.entities.impl.IUser#getId()
	 */
	public int getId() {
		return id;
	}

	/* (non-Javadoc)
	 * @see domain.entities.impl.IUser#setId(int)
	 */
	public void setId(int id) {
		this.id = id;
	}

	/* (non-Javadoc)
	 * @see domain.entities.impl.IUser#getLogin()
	 */
	public String getLogin() {
		return login;
	}

	/* (non-Javadoc)
	 * @see domain.entities.impl.IUser#setLogin(java.lang.String)
	 */
	public void setLogin(String login) {
		this.login = login;
	}

	/* (non-Javadoc)
	 * @see domain.entities.impl.IUser#getPassword()
	 */
	public String getPassword() {
		return password;
	}

	/* (non-Javadoc)
	 * @see domain.entities.impl.IUser#setPassword(java.lang.String)
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/* (non-Javadoc)
	 * @see domain.entities.impl.IUser#getContactGroups()
	 */
	public Set<IContactGroup> getContactGroups() {
		return contactGroups;
	}

	/* (non-Javadoc)
	 * @see domain.entities.impl.IUser#setContactGroups(java.util.Set)
	 */
	public void setContactGroups(Set<IContactGroup> contactGroups) {
		this.contactGroups = contactGroups;
	}

	/* (non-Javadoc)
	 * @see domain.entities.impl.IUser#removeContactGroup(int)
	 */
	public void removeContactGroup(int groupId) {
		IContactGroup cgToRemove = null;

		for(IContactGroup cg : contactGroups) {
			if(cg.getGroupId() == groupId) {
				cgToRemove = cg;
				break;
			}
		}


		if(cgToRemove != null) {
			contactGroups.remove(cgToRemove);
		}
	}
}
